package com.yunao.service.impl;

import com.yunao.dao.UserRepsitory;
import com.yunao.entity.User;
import com.yunao.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserRepsitory userRepsitory;

    @Override
    public List<User> findByOrgan(Integer organId) {
        return userRepsitory.findByOrganId(organId);
    }

    @Override
    public User findByUsername(String username) {
        return userRepsitory.findByUsername(username);
    }

    @Override
    public User findOne(Integer id) {
        return userRepsitory.findById(id).get();
    }

    @Override
    public void save(User user) {
        userRepsitory.save(user);
    }


    @Override
    public void delete(Integer id) {
        userRepsitory.deleteById(id);
    }

    @Override
    public void updateOpenidByUserid(@RequestParam("openid") String openid, @RequestParam("userid") String userid) {
        userRepsitory.updateOpenidByUserId(openid,userid);
    }

}
